<template>
	<up-navbar bgColor="transparent">
		<template #left>
			<view class="u-flex u-flex-items-center">
				<view class="f-s-16 u-m-r-12 u-main-color f-w-b">慈溪市</view>

			</view>
		</template>
	</up-navbar>

	<view class="home-top" :style="{
		padding: `${bottom + 24}px 32rpx 28rpx`
	}">

		<view class="u-flex u-flex-items-center">
			<view class="f-s-24 f-w-b" v-if="Object.keys(userInfo).length > 0">您好，{{ userInfo.name }}</view>
			<view class="f-s-24 f-w-b" v-else @click="login">您好，<text class="main-color">请登录</text></view>
		</view>

		<view  class="f-s-14 u-content-color u-m-t-16">欢迎使用车辆管理系统</view>

		<view class="entp-box u-flex u-flex-between u-flex-items-center">
			<view class="u-flex u-flex-items-center">
				<image src="@/static/entp-qrcode.png" style="width: 88rpx;height: auto;" mode="widthFix"></image>
				<view class="f-s-14 f-w-b u-m-l-10">企业二维码</view>
			</view>
			<view>
				<up-button text="查看" shape="circle" size="small" iconColor="#fff" color="#1677FF" :customStyle="{
					width: '140rpx',
					height: '56rpx'
				}" @click="entQrCode"></up-button>
			</view>
		</view>

		<view class="home-area">

			<block v-if="pageData.appList.length > 0">
				<up-grid :border="false" :col="4">
					<up-grid-item v-for="app in pageData.appList" :key="app.id" @click="toPage(app)">
						<image :src="app.logo" style="width: 120rpx;height: 120rpx;"></image>
						<view class="f-s-12 u-content-color u-m-b-40">{{app.name}}</view>
					</up-grid-item>
				</up-grid>
			</block>

			<view v-else class="u-p-b-40">
				<up-empty :marginTop="16" mode="data" text="暂无应用" :width="80" :height="80"
					icon="https://imgs.ddeke.com/2024/08/01/C5UsP1Ggo6.png">
				</up-empty>
			</view>

		</view>

		<view class="msg-box u-flex u-flex-between u-flex-items-center">
			<view class="u-flex u-flex-items-center" @click="toGaoInfo">
				<image src="@/static/message.png" mode="widthFix" style="width: 40rpx;height: auto;"></image>
				<view style="width: 150rpx" class="f-s-12 u-m-l-20 msg-text">消息通知</view>
				<view class="_line"></view>
				<view class="f-s-12 u-light-color">{{gaoData.title}}</view>
			</view>
			<image src="@/static/right.png" style="width: 32rpx;height: 32rpx;"></image>
		</view>
		<view class="f-s-16 f-w-b u-m-t-26" v-if="type==2">待办任务</view>
    <view class="message" v-if="items.length>=1&&type==2">

      <view v-for="(v, i) in items" :key="i" v-if="items.length>=1">
        <view class="page-item" style="background-color: white;"  @click="clickThing(v)">

          <!--        <view :class="['status', v.status == 2 ? 'success' : '']">{{v.status == 1 ? '未办结' : '已办结'}}</view>-->
          <view class="title u-line-1 line">{{typeNameEnum[v.type]}}</view>
          <view class="info">
            <view class="flex">
              <view class="ps">
                <view class="psitem">
                  <label>{{typeNameEnum[v.type]}}</label>
                </view>
                <view class="psitem">
                  <text >提交时间： {{'2024-12-01'}}</text>
                </view>
              </view>
            </view>
          </view>

        </view>

      </view>
    </view>

    <view style="height: 300rpx">
      <up-empty v-if="items.length<1&&type==2" :marginTop="60" :marginBottom="60" mode="data" text="暂无待办事项" :width="80" :height="80"
                icon="https://imgs.ddeke.com/2024/08/01/C5UsP1Ggo6.png">
      </up-empty>
    </view>




    <view class="message" v-if="type==1">
        <view class="page-item" >


            <card-box type="index" title="我的公寓档案">
              <template v-if="Object.keys(info).length>=1" #area>

                <view class="inde" @click="toEdit('person')">
                  <up-icon name="edit-pen" color="#0170ea" :size="20"></up-icon>
                  <view class="edit">
                    编辑
                  </view>
                </view>

                <view class=" u-flex u-flex-self-start f-s-14">
                  <view class="_title u-tips-color">住户姓名</view>
                  <view class="m-l-30">{{ info.name }}</view>
                </view>

                <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                  <view class="_title u-tips-color">住户性别</view>
                  <view class="m-l-30">{{ info.sex==0?'男':info.sex==1?'女':'未知' }}</view>
                </view>

                <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                  <view class="_title u-tips-color">身份证号</view>
                  <view class="m-l-30">{{ info.idCard || '-' }}</view>
                </view>

                <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                  <view class="_title u-tips-color">工作单位</view>
                  <view class="m-l-30">{{ info.workUnit || '-' }}</view>
                </view>

                <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                  <view class="_title u-tips-color">户籍地址</view>
                  <view class="m-l-30">{{ info.domicileAddr || '-' }}</view>
                </view>

                <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                  <view class="_title u-tips-color">出生日期</view>
                  <view class="m-l-30">{{ info.homeAddress || '-' }}</view>
                </view>

                <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                  <view class="_title u-tips-color">学历信息</view>
                  <view class="m-l-30">{{ info.qualification || '-' }}</view>
                </view>

                <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                  <view class="_title u-tips-color">政治面貌</view>
                  <view class="m-l-30">{{ info.politicalStatus==1?'群众':'党员' }}</view>
                </view>

                <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                  <view class="_title u-tips-color">人脸照片</view>
                  <image :src="info.facePhoto" class="face" mode="widthFix" />
<!--                  					<view>{{ info.phonenumber || '-' }}</view>-->
                </view>

                <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                  <view class="_title u-tips-color">登记时间</view>
                  <view class="m-l-30">{{ info.createTime || '-' }}</view>
                </view>

                <view class="ttit">
                  车辆信息
                </view>

                                <view class=" u-flex u-flex-self-start f-s-14">
                                  <view class="_title u-tips-color">车牌号</view>
                                  <view class="m-l-30">{{ info.carId }}</view>
                                </view>
                                <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                                  <view class="_title u-tips-color">车主姓名</view>
                                  <view class="m-l-30">{{ info.carOwnerName }}</view>
                                </view>
                                <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                                  <view class="_title u-tips-color"> 车辆品牌</view>
                                  <view class="m-l-30">{{ info.carBrand }}</view>
                                </view>


              </template  >

              <template v-if="Object.keys(info).length<=1" #area>
                <view class="empty-box">
                  <view style="margin-bottom: 160rpx;margin-top: 140rpx">
                    <image src="../static/empty.png" style="width: 200rpx;height: 200rpx;"></image>
                    <up-button text="去录入" style="margin-top: 120rpx" :customStyle="{
					width: '130rpx',
					height: '56rpx',
          marginTop:'60rpx',
					background: '#1677FF',
					borderRadius: '8rpx',
					fontSize: '28rpx',
					color: '#FFFFFF'
				}" @click="toInsert('person')"></up-button>
                  </view>

                </view>

              </template>
            </card-box>

<!--场所详情-->
          <card-box type="index" title="公寓场所档案" style="margin-top: 50rpx">
            <template v-if="Object.keys(shopInfo).length>=1" #area>

              <view class="inde" @click="toEdit('shop')">
                <up-icon name="edit-pen" color="#0170ea" :size="20"></up-icon>
                <view class="edit">
                  编辑
                </view>
              </view>

              <view class=" u-flex u-flex-self-start f-s-14">
                <view class="_title u-tips-color">场所名称</view>
                <view class="m-l-30">{{ shopInfo.operateName }}</view>
              </view>
              <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                <view class="_title u-tips-color">场所类型</view>
                <view class="m-l-30">{{ shopInfo.operateType }}</view>
              </view>
              <view class=" u-flex u-flex-self-start f-s-14 u-m-t-32">
                <view class="_title u-tips-color">法人姓名</view>
                <view class="m-l-30">{{ shopInfo.legal }}</view>
              </view>

              <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                <view class="_title u-tips-color">法人身份证号</view>
                <view class="m-l-30">{{ shopInfo.legalCard || '-' }}</view>
              </view>

              <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                <view class="_title u-tips-color">法人联系方式</view>
                <view class="m-l-30">{{ shopInfo.legalTel || '-' }}</view>
              </view>

              <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                <view class="_title u-tips-color">法人住址</view>
                <view class="m-l-30">{{ shopInfo.legalAddr || '-' }}</view>
              </view>
              <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                <view class="_title u-tips-color">登记时间</view>
                <view class="m-l-30">{{ shopInfo.createTime || '-' }}</view>
              </view>


              <view class="ttit">
                车辆信息
              </view>
              <view class=" u-flex u-flex-self-start f-s-14">
                <view class="_title u-tips-color">联系人姓名</view>
                <view class="m-l-30">{{ shopInfo.legalAddr }}</view>
              </view>
              <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                <view class="_title u-tips-color">联系人职位</view>
                <view class="m-l-30">{{ shopInfo.legalAddr }}</view>
              </view>
              <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                <view class="_title u-tips-color"> 联系人电话</view>
                <view class="m-l-30">{{ shopInfo.legalAddr }}</view>
              </view>



              <view class="ttit">
                车辆信息
              </view>
              <view class=" u-flex u-flex-self-start f-s-14">
                <view class="_title u-tips-color">经营许可证号</view>
                <view class="m-l-30">{{ shopInfo.operateCard }}</view>
              </view>
              <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                <view class="_title u-tips-color">许可证有效期</view>
                <view class="m-l-30">{{ shopInfo.operateDate }}</view>
              </view>
              <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                <view class="_title u-tips-color"> 许可范围</view>
                <view class="m-l-30">{{ shopInfo.operateScope }}</view>
              </view>
              <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                <view class="_title u-tips-color">发证机关</view>
                <view class="m-l-30">{{ shopInfo.issuingAuthority }}</view>
              </view>
              <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                <view class="_title u-tips-color">许可证状态</view>
                <view :class="shopInfo.operateStatus==0?'success':shopInfo.operateStatus==1?'warning':'fail'" >{{ shopInfo.operateStatus==0?'正常':shopInfo.operateStatus==1?'过期':'吊销'}}</view>
              </view>



              <view class=" u-flex u-flex-self-start u-m-t-32 f-s-14">
                <!--          https://hcimg.wq-info.com/cxhc/2024/08/22/index-bg_195221323A001.png-->
                <!--          <view class="_title u-tips-color">人脸照片</view>-->
                <image :src="shopInfo.operatePhoto" class="zheng" mode="widthFix" />
                <!--					<view>{{ info.phonenumber || '-' }}</view>-->
              </view>


            </template  >

            <template v-if="Object.keys(shopInfo).length<=1" #area>
              <view class="empty-box">
                <view style="margin-bottom: 160rpx;margin-top: 140rpx">
                  <image src="../static/empty.png" style="width: 200rpx;height: 200rpx;"></image>
                  <up-button text="场所录入" style="margin-top: 120rpx" :customStyle="{
					width: '130rpx',
					height: '56rpx',
          marginTop:'60rpx',
					background: '#1677FF',
					borderRadius: '8rpx',
					fontSize: '28rpx',
					color: '#FFFFFF'
				}" @click="toInsert('shop')"></up-button>
                </view>

              </view>

            </template>
          </card-box>

        </view>

    </view>

<!--		<up-empty v-else :marginTop="60" mode="data" text="暂无代办" :width="80" :height="80"-->
<!--			icon="https://imgs.ddeke.com/2024/08/01/C5UsP1Ggo6.png">-->
<!--		</up-empty>-->
	</view>

	<up-popup :show="show" @close="show = false" :safeAreaInsetBottom="false" :round="12" mode="center">
		<view class="notice-box">
			<view class="text-center f-s-18 f-w-b">系统通知</view>
			<view class="f-s-14 u-info u-m-t-34">警企通用户您好，</view>
			<view class="f-s-14 u-m-t-16">{{ notice.noticeTitle }}</view>
			<view class="f-s-14 u-m-t-8 u-info">
				{{ notice.noticeContent }}
			</view>
			<view class="f-s-12 u-m-t-16 u-light-color">
				{{ notice.createTime }} 由{{ notice.createBy }}发布
			</view>
			<up-button text="知道了" :customStyle="{
				width: '500rpx',
				height: '80rpx',
				background: '#1677FF',
				borderRadius: '16rpx',
				fontSize: '28rpx',
				color: '#FFFFFF',
				marginTop: '32rpx'
			}" @click="show = false"></up-button>

		</view>
	</up-popup>

</template>

<script setup>
	import AppItem from '@/components/AppItem.vue';
	import WeatherIcon from '@/components/WeatherIcon.vue';
	import UQRCode from 'uqrcodejs';
	import {
		homeData,
		appData,
		noticeData,
		noticeInfo
	} from '@/api/home.js'
	import {
		ref
	} from 'vue';
	import {
		onShow,
		onShareAppMessage
	} from "@dcloudio/uni-app"
	import store from '@/store/index.js';
	import {
		toast
	} from '../utils/common';
  import {messageList} from "../api/message";
  import CardBox from '@/components/common/CardBox.vue';
  import {householdDetails, householdList} from "../api/household";
  import storage from "../utils/storage";
  import {testApi} from "../api/apartment";
  import {roomDetails, roomList} from "../api/room";
  import {doingThings} from "../api/home";
  import {infomList} from "../api/gao";
	// 微信小程序环境
	// #ifdef MP-WEIXIN
	const bottom = uni.getMenuButtonBoundingClientRect().bottom
	// #endif
	// 其他环境
	// #ifndef MP-WEIXIN
	const bottom = 20

	// #endif

	const show = ref(false)

	const pageData = ref({
		// weather: {},
		appList: [],
		noticeList: [],
		enterprise: {}
	})

  const type = ref(2)
  let total = 0;
  let pageNum = 1;
  let pageSize = 100;
  const items = ref([]);
	const notice = ref({})
	const userInfo = ref({})
  const getInspectList = () => {

    // if (loading.value) return;
    // loading.value = true;
    let options = {
      pageSize,
      pageNum
    };

    // if (tabId.value != 0) {
    //   options.status = tabId.value;
    // }
    // 搜索参数
    // if (keyword.value.trim() != "") {
    // options.name = keyword.value.trim();
    // }

    // messageList(options).then(res => {
    //   // loading.value = false;
    //   if (res.code != 200) {
    //     toast(res.msg);
    //     return;
    //   }
    //
    //   total = res.total;
    //   items.value = pageNum == 1 ? res.rows : items.value.concat(res.rows);
    //   pageNum = pageNum + 1;
    //
    // }).catch(err => {
    //   // loading.value = false;
    // })
  }
	const tabList = [{
		name: '待办任务'
	}]

  const clickThing = (e)=>{

    // console.log('8877777')
    // console.log(e)
    if(e.type=='roomCheck'){
      uni.navigateTo({
        url:  '/subPackages/apartment/shopinfo?id='+e.id
      })
    } else if (e.type=='householdCheck'){
      uni.navigateTo({
        url:  '/subPackages/apartment/user_info?id='+e.id
      })
    } else if (e.type=='handlingCheck'){
      uni.navigateTo({
        url:  '/subPackages/apartment/warning?id='+e.id
      })
    } else if (e.type=='feedBackCheck'){
      uni.navigateTo({
        url:  '/subPackages/inspect/info?id='+e.id
      })
    }
  }

  const typeNameEnum = {
    roomCheck:'公寓场所核查',
    householdCheck:'公寓人员核查',
    handlingCheck:'群众举报',
    feedBackCheck:'微报警',
  }


	onShow(() => {
		userInfo.value = store.getters.userInfo
    console.log('_____',userInfo.value)
		init()
    getDoingThings()
    getGao()
	})

  const gaoData = ref({ title:'暂无通知 '})
  const getGao = ()=>{
    infomList({pageSize:10,pageNum:1}).then(res => {
      if (res.code != 200) {
        toast(res.msg);
        return;
      }
      if(res.rows.length>1){
        gaoData.value = res?.rows[0]
      }

    }).catch(err => {
      loading.value = false;
    })
  }

  const toGaoInfo = ()=>{
    uni.navigateTo({
      url: '/subPackages/gao/info?id='+gaoData.value.id
    })
  }

	const login = () => {
		// 微信小程序环境
		// #ifdef MP-WEIXIN
		uni.navigateTo({
			url: '/pages/login'
		})
		// #endif
		// 其他环境
		// #ifndef MP-WEIXIN
		uni.navigateTo({
			url: '/pages/account_login'
		})
		// #endif
	}


	const toPage = (e) => {
		const page = e.page
		if (!page) {
			toast("正在完善中...")
			return
		}
		uni.navigateTo({
			url: page
		})
	}


	const showNotice = (id) => {
		noticeInfo(id).then(resp => {
			notice.value = resp.data
			show.value = true
		})
	}

  const getDoingThings = ()=>{

    doingThings({userId:userInfo.value.userId}).then(res=>{
      items.value = res
    })

  }

  const getinfoCard = ()=>{
    householdList({userId:userInfo11.userId}).then(res=>{
      if(res.rows[0]){
        info.value = res.rows[0]
      }
    })
    roomList({createBy:userInfo11.userId}).then(res=>{

      // console.log('000000')
      // console.log(Object.values(res)[0][0])
      if(Object.keys(res).length>1 ){

        shopInfo.value = Object.values(res)[0][0]
      }

    })
  }

	const init = () => {
		homeData().then(resp => {
      pageData.value = resp.data
      // if(isLogin){
        getInspectList()

      setTimeout(()=>{
        if(userInfo.value.name===''||userInfo.value.name===null){
          userInfo.value.name = resp?.resp?.data?.enterprise?.asName
         }
      },1000)

      store.dispatch('GetInfo').then(res => {

      })

      const userInfoNew = storage.get('user_info');

      // if(resp.data.enterprise?.entID==null && resp.data.enterprise!==null && resp.data.isLogin==true){
      //   console.log('122121')
      //   console.log(userInfo11)
      //   uni.navigateTo({
      //     url: '/pages/registered'
      //   })
      // }

      if(resp.data?.enterprise?.roleName){
        type.value = 2
      }

      // console.log('5555555')
      // console.log(pageData.value)
      //

      if(!resp.data.isLogin){

        // console.log('88888')
        pageData.value.appList.push(
            {
              createAt: "2024-09-14",
              id: 12,
              logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
              name: "微报警",
              page: "/subPackages/microalarm/list",
              status: 1,
              text: "微报警",
              updateAt: "2024-09-18T10:38:48.000+08:00",
            }
        )
        // pageData.value.appList.push(
        //     {
        //       createAt: "2024-09-14",
        //       id: 6,
        //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
        //       name: "审批",
        //       page: "/subPackages/approval/list",
        //       status: 1,
        //       text: "审批",
        //       updateAt: "2024-09-18T10:38:48.000+08:00",
        //     }
        // )
      }

      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 6,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "审批",
      //       page: "/subPackages/approval/list",
      //       status: 1,
      //       text: "审批",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )

      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 6,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "接触镜",
      //       page: "/subPackages/police/list",
      //       status: 1,
      //       text: "接触镜",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )

      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 6,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "审批",
      //       page: "/subPackages/approval/list",
      //       status: 1,
      //       text: "审批",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )

      //
      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 7,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "违停（交警）",
      //       page: "/subPackages/illegalpark/list?type=1",
      //       status: 1,
      //       text: "违停（交警）",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )
      //
      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 7,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "违停（城管）",
      //       page: "/subPackages/illegalpark/list?type=2",
      //       status: 1,
      //       text: "违停（城管）",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )
      //
      //
      //
      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 8,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "消防检查",
      //       page: "/subPackages/firecheck/list",
      //       status: 1,
      //       text: "消防检查",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )

      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 9,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "日常巡查",
      //       page: "/subPackages/dailyinspect/list",
      //       status: 1,
      //       text: "日常巡查",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )

      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 10,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "楼宇检查",
      //       page: "/subPackages/buildingcheck/list",
      //       status: 1,
      //       text: "楼宇检查",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )

      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 11,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "楼宇垃圾分类",
      //       page: "/subPackages/rubsort/list",
      //       status: 1,
      //       text: "楼宇垃圾分类",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )
      //
      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 12,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "沿街店铺检查",
      //       page: "/subPackages/shop/list",
      //       status: 1,
      //       text: "沿街店铺检查",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )
      //
      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 12,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "交警执勤",
      //       page: "/subPackages/duty/list",
      //       status: 1,
      //       text: "交警执勤",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )
      //
      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 12,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "工地检查",
      //       page: "/subPackages/construction/list",
      //       status: 1,
      //       text: "工地检查",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )
      //
      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 12,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "微报警",
      //       page: "/subPackages/microalarm/list",
      //       status: 1,
      //       text: "微报警",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )

      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 12,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "公告管理",
      //       page: "/subPackages/gao/list",
      //       status: 1,
      //       text: "公告管理",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )


      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 12,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "数据统计",
      //       page: "/subPackages/data/list",
      //       status: 1,
      //       text: "数据统计",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )


      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 12,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "公寓管理",
      //       page: "/subPackages/apartment/list",
      //       status: 1,
      //       text: "公寓管理",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )


      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 12,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "涉黄举报",
      //       page: "/subPackages/report/porn",
      //       status: 1,
      //       text: "涉黄举报",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )


      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 12,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "涉赌举报",
      //       page: "/subPackages/report/mafia",
      //       status: 1,
      //       text: "涉黑举报",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )


      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 12,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "涉毒举报",
      //       page: "/subPackages/report/visit",
      //       status: 1,
      //       text: "涉访举报",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )


      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 12,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "消防检查",
      //       page: "/subPackages/report/fire",
      //       status: 1,
      //       text: "消防检查",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )


      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 12,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "群众求助",
      //       page: "/subPackages/report/help",
      //       status: 1,
      //       text: "群众求助",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )

      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 12,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "个人信息录入",
      //       page: "/subPackages/information/person",
      //       status: 1,
      //       text: "群众求助",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )


      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 12,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "场所信息录入",
      //       page: "/subPackages/information/shop",
      //       status: 1,
      //       text: "群众求助",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )


      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 12,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "录入信息",
      //       page: "/pages/registered",
      //       status: 1,
      //       text: "录入信息",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // )

			const isLogin = resp.data.isLogin

			if (!isLogin) {
				userInfo.value = {}
				// pageData.value.appList = []

        // pageData.value.appList.push(
        //     {
        //       createAt: "2024-09-14",
        //       id: 12,
        //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
        //       name: "完善信息",
        //       page: "/pages/registered",
        //       status: 1,
        //       text: "完善信息",
        //       updateAt: "2024-09-18T10:38:48.000+08:00",
        //     }
        // )
			}

      // pageData.value.appList.push(
      //     {
      //       createAt: "2024-09-14",
      //       id: 6,
      //       logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
      //       name: "审批",
      //       page: "/subPackages/approval/list",
      //       status: 1,
      //       text: "审批",
      //       updateAt: "2024-09-18T10:38:48.000+08:00",
      //     }
      // // )
      //
      pageData.value.appList.push(
          {
            createAt: "2024-09-14",
            id: 6,
            logo: "https://hcimg.wq-info.com/cxhc/2024/09/14/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240914141902_141923143A006.png",
            name: "楼宇",
            page: "/subPackages/building/list",
            status: 1,
            text: "楼宇",
            updateAt: "2024-09-18T10:38:48.000+08:00",
          }
      )




		})
	}

  const data1 = [
    {
      "id": "608ca105-570b-43f0-9f0a-202b17d52f13",
      "code": "CGYY",
      "name": "场馆预约",
      "entryCount": "291",
      "applyUserCount": "14",
      "actionCount": "467",
      "actionUserCount": "16",
      "bounceRate": null,
      "avgTime": "38天",
      "maxTime": "365天",
      "minTime": null,
      "__typename": "AppStat"
    },
    {
      "id": "45bb8435-1aff-4734-b116-537d9a48cdb7",
      "code": "tzcs",
      "name": "html编辑器通知测试",
      "entryCount": "174",
      "applyUserCount": "1",
      "actionCount": "141",
      "actionUserCount": "3",
      "bounceRate": null,
      "avgTime": "2天",
      "maxTime": "43天",
      "minTime": "3秒",
      "__typename": "AppStat"
    },
    {
      "id": "767758e1-2342-45ee-adb7-2673e38b8e78",
      "code": "ResourceReservation",
      "name": "资源预约",
      "entryCount": "91",
      "applyUserCount": "5",
      "actionCount": "60",
      "actionUserCount": "4",
      "bounceRate": null,
      "avgTime": "2天",
      "maxTime": "45天",
      "minTime": null,
      "__typename": "AppStat"
    }
  ]

  const sortMethod = (list, sort) => {
    let data = JSON.parse(JSON.stringify(list))
    let sortList = {'秒':[],'分钟':[],'小时':[],'天':[],'月':[],'年':[]}
    Object.keys(sortList).forEach((item, index) => {
      data.forEach(i=>{
        if(i.avgTime.indexOf(item) !== -1){
          sortList[item].push(i)
        }
      })
      sortList[item].sort((a, b)=>{
        return Number(a.avgTime.split(item)[0]) - Number(b.avgTime.split(item)[0])
      })
    })
    const finalList =  [...sortList['秒'],...sortList['分钟'],...sortList['小时'],...sortList['天'],...sortList['月'],...sortList['年']]
    if(sort==='desc'){
      return finalList.reverse()
    }else{
      return finalList
    }
  }

	const entQrCode = () => {
		if(!pageData.value.enterprise){
      pageData.value.enterprise = {}
      pageData.value.enterprise.entID = 'test'
      pageData.value.enterprise.entName = 'test'
			toast('暂无企业二维码')
			// return
		}


		uni.navigateTo({
			url: `/pages/entQrcode?id=${pageData.value?.enterprise?.entID}&name=${pageData.value?.enterprise?.entName}`
		})
	}

  store.dispatch('GetInfo').then(res => {

  })


  const userInfo11 = storage.get('user_info');


  // if(userInfo11.entId==null && Object.keys(userInfo11).length >0){
  //   console.log('122121')
  //   console.log(userInfo11)
  //   uni.navigateTo({
  //     url: '/pages/registered'
  //   })
  // }


  const toEdit = (e)=>{
    console.log(e)

    if(e=='person'){


      uni.navigateTo({
        url: '/subPackages/information/pedit?id='+info.value.id
      })
    }else if(e=='shop'){

      console.log('ssssss')
      uni.navigateTo({
        url: '/subPackages/information/sedit?id='+userInfo11.userId
      })
    }
  }

  const info = ref({})
  const shopInfo = ref({})





  const toInsert = (e)=>{
    if(e=='person'){
      uni.navigateTo({
        url: '/subPackages/information/person'
      })
    }else if(e=='shop'){
      uni.navigateTo({
        url: '/subPackages/information/shop'
      })
    }
  }


  // testApi( ).then(res=>{
  //   console.log('2222')
  //   console.log(res)
  // })


</script>

<style lang="scss">
.success{
  color: #00CC00;
  margin-left: 30rpx;
}

.fail{
  color: #FF0000;
  margin-left: 30rpx;
}

.warning {
  color: #de851d;
  margin-left: 30rpx;
}
.empty-box{
  width:100%;
  display: flex;
  justify-content: center;
}
.idcard{
  width: 100%;
  background-image: linear-gradient(rgba(33, 160, 252, 0.4), rgba(64, 176, 246, 0.05));
}

.ttit{
  font-weight: bold;
  margin: 40rpx 0 !important;
}
.edit{

  color: #015dc2;
  font-size: 26rpx;

}

.inde{
  display: flex;
  position: relative;
  top: -74rpx;
  right: -520rpx;
  //flex-direction: row;
}

.line{
  padding: 24rpx;
  border-bottom: 1rpx solid rgba(0,0,0,0.06);
}
.message{
  margin-top: 30rpx;
  margin-bottom: 60rpx;
  padding-bottom: 15rpx;
  //background-color: ;
  //height: 400rpx;


  //overflow: auto;
}
.m-l-30{
  margin-left: 30rpx;
}

.page {
  padding-bottom: 40rpx 0  calc(120rpx + env(safe-area-inset-bottom)) 0;
  &-search {
    background: #fff;
    padding-bottom: 12rpx;
    position: sticky;
    top: 0;
    z-index: 100;
    .input {
      padding: 12rpx 24rpx;
      border: 1rpx solid rgba(0,0,0,0.06);
    }
  }

  &-items {
    padding: 204rpx 0;
  }


  &-item {
    border-radius: 16rpx;
    //background: #FFF;
    box-shadow: 0rpx 2rpx 20rpx 0rpx rgba(0,0,0,0.05);
    width: 684rpx;
    margin: 0 auto;
    margin-bottom: 24rpx;
    box-sizing: border-box;
    position: relative;
    .status {
      display: inline-block;
      min-width: 76rpx;
      line-height: 32rpx;
      background: #FFF4D1;
      border-radius: 4rpx;
      font-size: 20rpx;
      color: #F27900;
      text-align: center;
      position: absolute;
      right: 32rpx;
      top: 36rpx;
      &.success {
        color: #1677FF;
        background: rgba(22,119,255,0.1);
      }
    }
    .title {
      width: 480rpx;
      line-height: 35rpx;
      font-size: 28rpx;
      font-weight: 500;
      color: rgba(0,0,0,0.85);

    }
    .info {
      padding: 24rpx 32rpx;
      border-bottom: 1rpx solid rgba(0,0,0,0.06);
    }
    .flex {
      display: flex;
    }
    .cover {
      width: 160rpx;
      height: 160rpx;
      border-radius: 8rpx;
      overflow: hidden;
      background: #D8D8D8;
      margin-right: 24rpx;
      .image {
        width: 160rpx;
        height: 160rpx;
        border-radius: 8rpx;
      }
    }
    .ps {
      flex: 1;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
    }
    .psitem {
      display: flex;
      margin-bottom: 16rpx;
    }
    .psitem label {
      width: auto;
      font-size: 32rpx;
      //color: rgba(0,0,0,0.45);
      line-height: 40rpx;
      margin-right: 24rpx;
      font-weight: bold;
    }
    .psitem text {
      font-size: 25rpx;
      color: rgba(0,0,0,0.85);
      line-height: 40rpx;
      flex: 1;
      color: #adacac;
    }
    .desc {
      background: rgba(0,0,0,0.04);
      border-radius: 8rpx;
      padding: 24rpx;
      font-size: 28rpx;
      color: rgba(0,0,0,0.85);
      line-height: 40rpx;
    }
    .btns {
      padding: 24rpx 32rpx;
      //display: flex;
      //justify-content: flex-end;
    }
    .btn {
      min-width: 120rpx;
      height: 56rpx;
      background: #FFFFFF;
      border-radius: 8rpx;
      border: 1rpx solid #E5E5E5;
      font-size: 28rpx;
      color: rgba(0,0,0,0.65);
      display: flex;
      align-items: center;
      justify-content: center;
      margin-left: 24rpx;
      &.primary {
        background: #1677FF;
        color: #FFF;
        border: none;
      }
    }
  }

  &-addButton {
    position: fixed;
    bottom: 136rpx;
    right: 32rpx;
    border-radius: 50%;
    width: 120rpx;
    height: 120rpx;
    background: #1677FF;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0rpx 4rpx 20rpx 0rpx rgba(22,119,255,0.5);
    image {
      width: 48rpx;
      height: 48rpx;
    }
  }
}
  .psitem {
    display: flex;
    margin-bottom: 16rpx;
  }
  .psitem label {
    width: auto;
    font-size: 32rpx;
    //color: rgba(0,0,0,0.45);
    line-height: 40rpx;
    margin-right: 24rpx;
    font-weight: bold;
  }
  .psitem text {
    font-size: 25rpx;
    color: rgba(0,0,0,0.85);
    line-height: 40rpx;
    flex: 1;
    color: #adacac;
  }

	.home-top {
		height: 430rpx;
		background-image: url(https://hcimg.wq-info.com/cxhc/2024/08/22/index-bg_195221323A001.png);
		background-size: 100% 100%;
		background-repeat: no-repeat;
		width: 100%;
		box-sizing: border-box;
		position: relative;

		.entp-box {
			margin-top: 58rpx;
			width: calc(100vw - 64rpx);
			box-sizing: border-box;
			padding: 0 24rpx;
			height: 100rpx;
			background: linear-gradient(270deg, #B9DAFF 0%, #FFFFFF 100%);
			box-shadow: 0rpx 2rpx 20rpx 0rpx rgba(0, 0, 0, 0.05);
			border-radius: 12rpx;
		}

		// .user-box {
		// 	position: absolute;
		// 	width: calc(100vw - 64rpx);
		// 	background-image: url(https://imgs.ddeke.com/2024/07/30/Y7hOrrxAMr.png);
		// 	background-size: 100% 100%;
		// 	background-repeat: no-repeat;
		// 	box-sizing: border-box;
		// 	padding: 32rpx;
		// 	height: 202rpx;
		// 	margin-top: 32rpx;

		// 	.dept {
		// 		border-radius: 4rpx;
		// 		border: 1rpx solid rgba(22, 119, 255, 0.25);
		// 		padding: 6rpx 8rpx;
		// 		font-size: 20rpx;
		// 		color: #1677FF;
		// 		line-height: 20rpx;
		// 		margin-left: 24rpx;
		// 	}

		// 	.info-box {
		// 		padding-top: 20rpx;
		// 		border-top: 1rpx solid rgba(0, 0, 0, 0.06);
		// 	}

		// 	.msg-text {
		// 		color: #FF701D;
		// 	}

		// 	._line {
		// 		margin: 0 16rpx;
		// 		width: 1rpx;
		// 		height: 32rpx;
		// 		background: rgba(0, 0, 0, 0.06);
		// 	}
		// }

		.home-area {
			margin-top: 24rpx;
			padding: 40rpx 30rpx 4rpx;
			background: #ffffff;
			box-shadow: 0rpx 2rpx 20rpx 0rpx rgba(0, 0, 0, 0.05);
			border-radius: 16rpx;
		}

		.msg-box {
			margin-top: 24rpx;
			height: 88rpx;
			padding: 0 24rpx;
			background: linear-gradient(270deg, #FFFFFF 0%, #EFF5FF 100%);
			box-shadow: 0rpx 2rpx 20rpx 0rpx rgba(0, 0, 0, 0.05);
			border-radius: 16rpx;
			border: 2rpx solid #FFFFFF;

			.msg-text {
				color: #1677FF;
			}

			._line {
				margin: 0 16rpx;
				width: 1rpx;
				height: 32rpx;
				background: rgba(0, 0, 0, 0.06);
			}
		}
	}

	
</style>